﻿
#include "CTitleList.h"


//-------------------------------------------------------------------------------
CTitleList::CTitleList(uint32_t uid, uint32_t pn)
	: BaseMessage(uid, pn)
{
	_safe_guard_begin;
	_safe_guard_end;
}

//-------------------------------------------------------------------------------
CTitleList::~CTitleList(void)
{

}

//-------------------------------------------------------------------------------
void CTitleList::SetTitleListData(TitleSystem * titleData)
{
	_safe_guard_begin;

	Json::Value jv;
	Json::Value jv2;
	jv2.clear();

	uint32_t size = titleData->GetMaxValidElementCount();
	for (uint32_t i = 0; i < size; ++i )
	{
		jv.clear();
		title* p = titleData->GetTitleDataByIndex(i);
		_safe_check(p);

		uint32_t high = 0;
		uint32_t low = 0;
		if (p->m_deadline != 0 && p->m_title_id != 0)
		{
			high = (p->m_deadline) >> 32;
			low = (p->m_deadline) & 0xFFFFFFFF;//低32位有效
		}

		jv.append(p->m_title_id);
		jv.append(high);
		jv.append(low);
		jv.append(p->m_is_wear);

		jv2.append(jv);
	}

	if (jv2.empty() == false)
	{
		m_jv["titleInfo"] = jv2;
	}
	
	m_jv["ret"] = 0;

	_safe_guard_end;
}
